import { request, requestMock } from "@/utils/http";

//请求首页的三级分类列表
export const requestCategoryList = () => {
  return request.get("/api/product/getBaseCategoryList");
};

//请求banner数据
export const requestBannerList = () => {
  return requestMock.get("/banner");
};

//请求floor的数据
export const requestFloorList = () => {
  return requestMock.get("/floor");
};

//请求搜索页数据
export const requestSearchList = (params) => {
  return request.post("/api/list", params);
};

//根据skuId 请求某个商品详情的数据
export const requestDetailInfo = (skuId) => {
  return request.get(`api/item/${skuId}`);
};

//新增购物车 或者 修改购物车某个商品的数量 的请求
export const requestAddOrUpdataNumCart = ({ skuId, skuNum }) => {
  return request.post(`/api/cart/addToCart/${skuId}/${skuNum}`);
};

//获取购物车列表
export const requestShopCart = () => {
  return request.get(`/api/cart/cartList`);
};

// 修改单个商品的选中状态
export const requestUpdateSingleCheck = ({skuId,isChecked})=>{
  //接受两个参数
  return request.get(`/api/cart/checkCart/${skuId}/${isChecked}`)
};

// 修改所有购物车商品的选中状态
export const requestUpdateAllCheck = (isChecked,skuIdList)=>{
  return request.post(`/api/cart/batchCheckCart/${isChecked}`, skuIdList);
};

// 删除购物车单个商品
export const requestDeleteSingleGood = (skuId) =>{
  return request.delete(`/api/cart/deleteCart/${skuId}`);
};

//删除所有的购物车商品
export const requestDeleteAllGoods = (skuIdList)=>{
  return request.delete(`/api/cart/batchDeleteCart`,{
    data:skuIdList,
  });
};

//获取注册验证码
export const getRegisterCode = (phone) => {
  return request.get(`/api/user/passport/sendCode/${phone}`);
};

// 注册请求
export const requestRegister = (registerInfo) =>{
  return request.post(`/api/user/passport/register`, registerInfo);
};